var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "receiptNo",
			name : "单据编号"
		}, {
			colkey : "scheduleId",
			name : "班次",
			renderData : function(rowindex,data, rowdata, column) {
				if (data==1 || data=="1"){
					return "甲班";
				}else if (data==2 || data=="2"){
					return "乙班";
				}
			}
		}, {
			colkey : "planNo",
			name : "计划编号"
		}, {
			colkey : "date",
			name : "日期",
			renderData : function(rowindex, data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd");
			}
		}, {
			colkey : "receiptType",
			name : "单据类型",
			renderData : function(rowindex,data, rowdata, column) {
				if (data==1 || data=="1"){
					return "补打条码";
				}
			}
		}, {
			colkey : "username",
			name : "制单人"
		}, {
			colkey : "id",
			name : "序号"
		}, {
			colkey : "machineNo",
			name : "机台"
		}, {
			colkey : "mouldNo",
			name : "模具编号"
		}, {
			colkey : "materialNo",
			name : "物料编码"
		}, {
			colkey : "materialName",
			name : "物料名称"
		}, {
			colkey : "count",
			name : "包数"
		}, {
			colkey : "generatedLabel",
			name : "是否生成条形码",
			renderData : function(rowindex,data, rowdata, column) {
				if (data==0 || data=="0"){
					return "<font color='red'>否</font>";
				}else{
					return "<font color='blue'>是</font>";
				}
			}
		} ],
		jsonUrl : rootPath + '/label_reprint/label_reprint_findByPage.shtml',
		dymCol : true,
		checkbox : true,
		serNumber : false
	});
	$("#addFun").click("click", function() {
		addAccount();
	});
	$("#editFun").click("click", function() {
		editAccount();
	});
	$("#search").click("click", function() {//  绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});

});
function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer.open({
		title : "编辑补打标签",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/label_reprint/label_reprint_edit.shtml?id='+ cbox
	});
}
function addAccount() {
	pageii = layer.open({
		title : "新增补打标签",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/label_reprint/label_reprint_add.shtml'
	});
}
